package com.robot;


import com.robot.dao.*;
import com.robot.model.BuildMetric;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: li
 * Date: 2019/3/10
 * Time: 10:34
 * PROJECT：compass
 * PACKAGE: com.compass
 *
 * @author:55324936@qq.com To change this template use File | Settings | File Templates.
 */
@Controller
public class MainController {
    @Autowired
    BuildTestMapper buildTestMapper;
    @Autowired
    TestCaseMapper testCaseMapper;
    @Autowired
    UserMapper userMapper;
    @Autowired
    TestPlanMapper testPlanMapper;
    @Autowired
    InterfaceMapper interfaceMapper;

    /**
     * 整个工程访问的跟路径
     * @RequestMapping 是映射浏览器中url路径与方法之间的关系
     * **/
    @RequestMapping({"/","/index"})
    public ModelAndView index(){
        ModelAndView modelAndView=new ModelAndView();
        List<BuildMetric> buildMetricList=  buildTestMapper.buildDayMetric();
        modelAndView.addObject("buildMetricList",buildMetricList);

        Long testCaseCount= testCaseMapper.totalCount();
        modelAndView.addObject("testCaseCount",testCaseCount);

        Long testPlanCount=  testPlanMapper.totalCount();
        modelAndView.addObject("testPlanCount",testPlanCount);

        Long userCount=   userMapper.totalCount();
        modelAndView.addObject("userCount",userCount);

        Long componentCount=interfaceMapper.totalCount();

        modelAndView.addObject("componentCount",componentCount);
        return modelAndView;
    }
}
